import { createRouter, createWebHashHistory } from 'vue-router';
import store from '../store/store'

import views from './modules/view';

const router = createRouter({
    history: createWebHashHistory(),
    routes: [
        ...views,
        // {
        //     path: '/userCenter',
        //     meta: {
        //         title: '个人中心',
        //     },
        //     name: 'userCenter',
        //     redirect: '/userCenter/info',
        //     component: () => import('../views/userCenter/userCenter.vue'),
        //     children: [
        //         {
        //             path: 'info',
        //             meta: { title: '个人信息' },
        //             component: () => import('@/views/userCenter/userInfo.vue')
        //         },
        //     ]
        // },
    ]
});
router.beforeEach((to, from, next) => {
    if (to.meta.title) {
        document.title = to.meta.title
    }
    next()
    // const openid = store.getters.userInfo.openid;
    // if(!openid){
    //     if(to.name =='bindPhone' ){
    //         next()
    //     }else{
    //         router.push("bindPhone")
    //     }
    // }else{
    //     next()
    // }
})

router.afterEach((to, from, next) => {
    document.querySelector('html').scrollTop = 0
    if (to.meta.title) {
        document.title = to.meta.title
    }
})
export default router;
